Skip to content

Release 0.1.6#7

Merged
siy merged 3 commits intomainfrom
release-0.1.6
Dec 27, 2025
Merged

Release 0.1.6#7
siy merged 3 commits intomainfrom
release-0.1.6

Conversation

@siy
Copy link
Owner

@siy siy commented Dec 26, 2025

Summary

Release 0.1.6 with quality improvements from comprehensive code review.

Added

  • AST support in generated parsers (AstNode type + parseAst() method)
  • Packrat toggle in generated parsers (setPackratEnabled(boolean))
  • Unlimited $N action variable support (regex-based, removes $1-$20 limit)

Fixed

  • Grammar validation now detects undefined rule references
  • Thread safety: skippingWhitespace moved to ParsingContext
  • Packrat cache key collision risk (uses unique IDs instead of hashCode())

Changed

  • Builder API naming standardized: withPackrat()packrat(), etc.
  • Documentation cleanup (removed undocumented %word directive)
  • Updated pragmatica-lite dependency: 0.8.4 → 0.9.0

Test plan

  • All 271 tests pass
  • mvn verify succeeds
  • Version consistency verified
  • Documentation updated

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • AST parsing output
    • Runtime packrat memoization toggle
    • Unlimited positional action variables ($N)
  • Bug Fixes

    • Detect undefined grammar rule references during validation
    • Improved thread-safety for whitespace handling
    • Reduced packrat cache key collision risk
  • Changed

    • Builder API method names simplified (.packrat, .trivia, .recovery)
    • Config builder removed in favor of direct configuration record
  • Documentation

    • Examples and docs updated for API/name changes
  • Tests

    • Test coverage increased (new validation and regression tests)

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

Release 0.1.6 standardizes builder names, adds AST parsing, enables runtime packrat toggling, supports unlimited $N action variables, validates undefined grammar references, moves whitespace skipping into per-parse context, fixes packrat key collisions, and bumps pragmatica-lite to 0.9.0.

Changes

Cohort / File(s) Summary
Project metadata
pom.xml, CHANGELOG.md
Version bumped to 0.1.6; pragmatica-lite.version updated 0.8.40.9.0; release notes added.
Documentation & examples
README.md, CLAUDE.md, docs/ERROR_RECOVERY.md
Updated examples and docs to new builder method names (withXX), removed %word directive, updated test counts (268 → 271).
Public builder API
src/main/java/org/pragmatica/peg/PegParser.java, ...tests/examples...
Renamed builder methods: withPackrat(...)packrat(...), withTrivia(...)trivia(...), withErrorRecovery(...)recovery(...); updated call sites in tests/examples.
Parser generator & generated parsers
src/main/java/org/pragmatica/peg/generator/ParserGenerator.java, generated outputs
Added parseAst(String) and sealed AstNode (Terminal/NonTerminal); added setPackratEnabled(boolean) toggle in generated parse contexts; conditional cache creation/usage when packrat disabled.
Parsing engine / runtime context
src/main/java/org/pragmatica/peg/parser/PegEngine.java, src/main/java/org/pragmatica/peg/parser/ParsingContext.java
Moved whitespace skipping into ParsingContext (added isSkippingWhitespace(), enterWhitespaceSkip(), exitWhitespaceSkip()); introduced per-parse ruleIds numeric IDs for packrat keys; unified mode-aware expression parsing and centralized parse error builder.
Action compilation
src/main/java/org/pragmatica/peg/action/ActionCompiler.java, src/main/java/org/pragmatica/peg/generator/ParserGenerator.java
Replaced limited $1..$20 substitutions with regex-driven POSITIONAL_VAR handling to support unlimited $N; preserves $0 mapping.
Grammar validation
src/main/java/org/pragmatica/peg/grammar/Grammar.java, src/test/java/org/pragmatica/peg/grammar/GrammarParserTest.java
Added Grammar.validate() that detects undefined rule references (recursive traversal); added tests for undefined and nested undefined references.
Configuration & API surface
src/main/java/org/pragmatica/peg/parser/ParserConfig.java, src/main/java/org/pragmatica/peg/parser/ParseMode.java, src/main/java/org/pragmatica/peg/parser/ParseResultWithDiagnostics.java
Removed ParserConfig.Builder; configuration exposed via record-only API; added ParseMode and ParseResultWithDiagnostics public types.
Semantic values & source utilities
src/main/java/org/pragmatica/peg/action/SemanticValues.java, src/main/java/org/pragmatica/peg/tree/SourceLocation.java
Removed choice tracking from SemanticValues; removed SourceLocation.advanceColumn() and advanceLine().
Tests & new suites
src/test/java/org/pragmatica/peg/...*
Updated tests to new builder API names; added grammar validation tests and CutOperatorRegressionTest; overall test count increased to 271.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant Client
participant GeneratedParser
participant ParsingContext
participant PackratCache
participant CST
participant AstMapper
Note over Client,GeneratedParser: parseAst flow (new)
Client->>GeneratedParser: parseAst(input)
GeneratedParser->>ParsingContext: create context (packratEnabled?)
alt packrat enabled
ParsingContext->>PackratCache: init cache
else packrat disabled
note right of ParsingContext: cache = null (no memoization)
end
GeneratedParser->>GeneratedParser: parse rules (mode-aware)
GeneratedParser->>ParsingContext: read/write packrat entries (if cache != null)
GeneratedParser->>CST: build CST (if CST path)
CST->>AstMapper: toAst(cst)
AstMapper->>GeneratedParser: return AstNode
GeneratedParser->>Client: Result

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 I hopped through parsers, trimmed the grass,

Packrat on or off — I knew the class,
ASTs now bloom from every rule,
$N stretches wide — no cutoff school,
Whitespace guarded, keys counted fast. 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.57% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Release 0.1.6' accurately reflects the main objective of the pull request, which is to release version 0.1.6 with multiple improvements and bug fixes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch release-0.1.6

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CLAUDE.md (1)

72-72: Inconsistent test counts in documentation.

Line 72 states "14 tests for grammar parser" but line 284 states "Grammar Parser Tests (17 tests)". With 3 new validation tests added, the count on line 72 should be updated to 17.

🔎 Proposed fix
-│   └── GrammarParserTest.java  # 14 tests for grammar parser
+│   └── GrammarParserTest.java  # 17 tests for grammar parser
🧹 Nitpick comments (2)
src/main/java/org/pragmatica/peg/action/ActionCompiler.java (1)

95-108: LGTM! Unlimited $N support via regex.

The regex-based approach correctly enables unlimited positional action variables as described in the PR objectives.

🔎 Optional: Remove redundant n == 0 check

Line 104's n == 0 check is unreachable because $0 is already replaced with sv.token() on line 99, so the regex won't match it. You can simplify:

     private String transformActionCode(String code) {
         // Replace $0 with sv.token()
         var result = code.replace("$0", "sv.token()");
 
         // Replace $N (N > 0) with sv.get(N-1) using regex for unlimited support
         result = POSITIONAL_VAR.matcher(result).replaceAll(match -> {
             int n = Integer.parseInt(match.group(1));
-            return n == 0 ? "sv.token()" : "sv.get(" + (n - 1) + ")";
+            return "sv.get(" + (n - 1) + ")";
         });
 
         return result;
     }
src/main/java/org/pragmatica/peg/generator/ParserGenerator.java (1)

1385-1395: Consider adding a more descriptive rule name for error nodes.

The default case in toAst handles CstNode.Error nodes by returning a terminal with rule name "error" and empty text. While this is a reasonable fallback, the CST error node contains useful information (skippedText, expected) that is lost.

If error recovery is used and the AST is later traversed, consumers won't know what text was skipped or what was expected.

🔎 Possible enhancement to preserve error context
-                        default -> new AstNode.Terminal(cst.span(), "error", "");
+                        case CstNode.Error err -> new AstNode.Terminal(err.span(), "error", err.skippedText());
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e3d042 and bdbfa1b.

📒 Files selected for processing (15)
  • CHANGELOG.md
  • CLAUDE.md
  • README.md
  • docs/ERROR_RECOVERY.md
  • pom.xml
  • src/main/java/org/pragmatica/peg/PegParser.java
  • src/main/java/org/pragmatica/peg/action/ActionCompiler.java
  • src/main/java/org/pragmatica/peg/generator/ParserGenerator.java
  • src/main/java/org/pragmatica/peg/grammar/Grammar.java
  • src/main/java/org/pragmatica/peg/parser/ParsingContext.java
  • src/main/java/org/pragmatica/peg/parser/PegEngine.java
  • src/test/java/org/pragmatica/peg/ErrorRecoveryTest.java
  • src/test/java/org/pragmatica/peg/PegParserTest.java
  • src/test/java/org/pragmatica/peg/examples/ErrorRecoveryExample.java
  • src/test/java/org/pragmatica/peg/grammar/GrammarParserTest.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/test/java/org/pragmatica/peg/grammar/GrammarParserTest.java (1)
src/main/java/org/pragmatica/peg/grammar/GrammarParser.java (1)
  • GrammarParser (16-542)
🔇 Additional comments (21)
src/main/java/org/pragmatica/peg/parser/ParsingContext.java (3)

25-25: LGTM! Stable cache keys via ruleIds.

Using a dedicated map to assign numeric IDs to rule names provides deterministic cache keys, addressing hash collision risks mentioned in the PR objectives.

Also applies to: 50-50


42-43: LGTM! Thread-safe whitespace skipping guard.

Moving whitespace skipping state into ParsingContext with explicit enter/exit lifecycle methods improves thread safety and prevents recursive whitespace parsing.

Also applies to: 279-291


347-350: LGTM! Improved packrat key generation.

The new approach using ruleIds.computeIfAbsent ensures each rule gets a stable, unique numeric ID, then packs it with the position into a long. This is more reliable than hashCode-based keys.

src/main/java/org/pragmatica/peg/parser/PegEngine.java (2)

878-909: LGTM! Context-driven whitespace handling.

The refactoring moves whitespace skipping state from a local field to ParsingContext, improving thread safety. The enter/exit lifecycle ensures proper cleanup.


915-922: LGTM! Helper for trivia collection.

The extractInnerExpression helper correctly unwraps repetition operators (ZeroOrMore, OneOrMore, Optional) to allow matching whitespace elements one at a time for proper trivia collection.

src/test/java/org/pragmatica/peg/PegParserTest.java (1)

268-275: LGTM! Builder API rename applied.

The update from withPackrat(true) to packrat(true) aligns with the standardized builder API naming mentioned in the PR objectives.

docs/ERROR_RECOVERY.md (1)

35-35: LGTM! Documentation updated for API rename.

The examples now correctly use .recovery(RecoveryStrategy) instead of .withErrorRecovery(RecoveryStrategy), consistent with the builder API standardization.

Also applies to: 48-48, 61-61, 77-77, 409-409, 412-412, 415-415, 486-486, 528-528, 556-556

src/main/java/org/pragmatica/peg/grammar/Grammar.java (2)

53-67: LGTM! Grammar validation for undefined references.

The validate() method now detects undefined rule references as mentioned in the PR objectives. It properly returns a SemanticError with the rule name and location when an undefined reference is found.


69-110: LGTM! Comprehensive expression traversal.

The findUndefinedReference helper correctly handles all expression types, including sequences, choices, repetitions, and nested structures. Terminal expressions appropriately return Option.none().

src/test/java/org/pragmatica/peg/examples/ErrorRecoveryExample.java (1)

46-46: LGTM! Test examples updated for API rename.

All test methods now use .recovery(RecoveryStrategy) instead of .withErrorRecovery(RecoveryStrategy), consistent with the builder API standardization.

Also applies to: 63-63, 77-77, 138-138, 208-208, 233-233, 250-250, 277-277, 304-304

src/test/java/org/pragmatica/peg/grammar/GrammarParserTest.java (1)

185-226: LGTM! Solid test coverage for grammar validation.

The three new tests appropriately cover:

  • Direct undefined rule references
  • Valid grammar (positive case)
  • Nested undefined references within complex expressions

The test structure follows the existing patterns in the file and the assertions clearly verify the expected behavior.

src/test/java/org/pragmatica/peg/ErrorRecoveryTest.java (1)

47-47: LGTM! Builder API consistently updated.

All usages of .withErrorRecovery(...) have been correctly renamed to .recovery(...) across the test file, aligning with the standardized builder API naming convention.

src/main/java/org/pragmatica/peg/PegParser.java (1)

134-147: LGTM! Builder API naming standardization.

The method renames from withX() to X() follow a more concise builder pattern. This is a breaking change that is properly documented in the CHANGELOG.

CLAUDE.md (1)

174-176: LGTM! API examples correctly updated.

The configuration examples now reflect the standardized builder method names (packrat(), trivia(), recovery()).

README.md (1)

25-25: LGTM! Version and documentation correctly updated.

The version bump to 0.1.6 and all API examples have been updated to reflect the standardized builder method names.

CHANGELOG.md (1)

8-51: LGTM! Comprehensive and well-structured changelog entry.

The release notes clearly document:

  • New features (AST support, packrat toggle, unlimited action variables)
  • Bug fixes (grammar validation, thread safety, cache key collision)
  • Breaking changes (API renames) with migration path

This follows the Keep a Changelog format and provides good context for users upgrading.

src/main/java/org/pragmatica/peg/generator/ParserGenerator.java (5)

196-212: LGTM! Packrat memoization toggle correctly implemented.

The implementation properly:

  • Defaults to enabled (preserving existing behavior)
  • Initializes cache as null when disabled to avoid memory allocation
  • Guards all cache operations with null checks

294-302: LGTM! Cache lookup correctly guarded.

The null check ensures no NPE when packrat is disabled.


752-761: LGTM! Unlimited action variable support.

The regex-based replacement correctly:

  • Uses a compiled Pattern for efficiency
  • Handles $0 specially (preserving it for matched text)
  • Converts 1-based $N to 0-based values.get(N-1)

951-957: LGTM! Clean AstNode interface design.

The sealed interface with Terminal and NonTerminal records provides a simple, immutable AST representation.


1470-1476: LGTM! CST cache lookup consistently guarded.

Mirrors the non-CST implementation correctly.

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>25</maven.compiler.release>
<pragmatica-lite.version>0.8.4</pragmatica-lite.version>
<pragmatica-lite.version>0.9.0</pragmatica-lite.version>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the pom.xml file to understand the context
git ls-files "*pom.xml*" | head -5

Repository: siy/java-peglib

Length of output: 66


🏁 Script executed:

# Search for pragmatica-lite in pom.xml and surrounding lines
rg "pragmatica-lite" -A 5 -B 5

Repository: siy/java-peglib

Length of output: 19372


🏁 Script executed:

# Check Maven Central for pragmatica-lite 0.9.0 availability
curl -s "https://search.maven.org/solrsearch/select?q=g:org.pragmatica-lite+AND+a:core+AND+v:0.9.0&rows=1&wt=json" | jq '.'

Repository: siy/java-peglib

Length of output: 501


🏁 Script executed:

# Check for repository configurations in pom.xml
cat pom.xml | head -100

Repository: siy/java-peglib

Length of output: 3379


🏁 Script executed:

# Check if pragmatica-lite 0.8.4 exists (previous version)
curl -s "https://search.maven.org/solrsearch/select?q=g:org.pragmatica-lite+AND+a:core&rows=10&wt=json" | jq '.response.docs[] | {v, timestamp}'

Repository: siy/java-peglib

Length of output: 41


🏁 Script executed:

# Check if there are any repository configurations
rg "repositories|url" pom.xml -A 2

Repository: siy/java-peglib

Length of output: 408


pragmatica-lite:core 0.9.0 is not available in Maven Central.

The dependency declared on line 41 cannot be resolved. Before releasing 0.1.6, either publish pragmatica-lite:core 0.9.0 to Maven Central or adjust the version to an available release (e.g., 0.8.4).

🤖 Prompt for AI Agents
In pom.xml around line 41, the pragmatica-lite.version property is set to 0.9.0
which is not available on Maven Central; either change that property to a
published version (e.g., 0.8.4) in the pom.xml and run a full build (mvn -U
clean verify) to ensure dependency resolution, or publish pragmatica-lite:core
0.9.0 to Maven Central following our release process and then leave the pom
unchanged.

@siy
Copy link
Owner Author

siy commented Dec 27, 2025

Re: pragmatica-lite:core 0.9.0 availability

The CI build passed successfully, which confirms that pragmatica-lite:core:0.9.0 is available from Maven Central. The dependency resolves correctly.

The CodeRabbit check may have been performed before the artifact was fully propagated across Maven Central mirrors, or used cached search results.

No action required - the dependency is available and the build works.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CLAUDE.md (1)

408-408: Update stale test count in build commands.

Line 408 references 268 passing tests, but the document states 271 tests overall (line 142 and 283). Update this comment to reflect the current test count.

🔎 Proposed fix
-mvn test             # Run tests (268 passing)
+mvn test             # Run tests (271 passing)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bdbfa1b and fdb9219.

📒 Files selected for processing (1)
  • CLAUDE.md

- Consolidated 3 duplicate expression parsing switch statements into unified parseExpressionWithMode()
- Extracted buildParseError() helper to eliminate duplicate error message construction
- Removed unused SemanticValues.choice field and getter
- Removed unused SourceLocation.advanceColumn()/advanceLine() methods
- Removed unused ParserConfig.Builder
- ~107 lines reduced in PegEngine.java

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/org/pragmatica/peg/parser/PegEngine.java (1)

821-842: Consider a more robust approach for distinguishing custom error messages.

The heuristic at lines 836-840 uses string prefix matching to differentiate custom error messages from standard ones. While this works with current message patterns, it's fragile and could break if:

  • A custom message happens to start with ', [, or other checked prefixes
  • New standard message formats are introduced that don't match these patterns
  • The list of checked patterns needs to be maintained as the grammar evolves

A more maintainable approach would be to explicitly mark custom messages using a flag or wrapper type (e.g., ParseResult.Failure.withCustomMessage(...)) rather than inferring from string content.

💡 Alternative approach using explicit marking

Instead of inferring from string patterns, you could:

  1. Add a field to ParseResult.Failure to indicate custom messages:
record Failure(SourceLocation location, String expected, boolean isCustomMessage) 
    implements ParseResult { ... }
  1. Then simplify the logic:
var expected = failureExpected instanceof Failure f && f.isCustomMessage()
    ? failureExpected.expected()
    : ctx.furthestExpected();

This makes the intent explicit and eliminates pattern-matching fragility.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdb9219 and bf928cc.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • CLAUDE.md
  • src/main/java/org/pragmatica/peg/action/SemanticValues.java
  • src/main/java/org/pragmatica/peg/parser/ParserConfig.java
  • src/main/java/org/pragmatica/peg/parser/PegEngine.java
  • src/main/java/org/pragmatica/peg/tree/SourceLocation.java
💤 Files with no reviewable changes (2)
  • src/main/java/org/pragmatica/peg/parser/ParserConfig.java
  • src/main/java/org/pragmatica/peg/tree/SourceLocation.java
🔇 Additional comments (10)
src/main/java/org/pragmatica/peg/action/SemanticValues.java (4)

10-10: LGTM! Clean removal of unused choice tracking.

The removal of the choice field is consistent throughout the file—constructor, factory method, and toString are all updated. The semantic values API is now simpler and focused on matched text and child values.

Also applies to: 18-26, 136-136


77-77: Excellent centralization of error construction logic.

The new buildParseError() helper eliminates duplicate error message construction across parseCst() and parse() methods. The logic correctly uses the furthest location tracked during backtracking (ctx.furthestLocation(), ctx.furthestPos(), ctx.furthestExpected()) to provide accurate error positions and messages.

Also applies to: 134-134, 821-842


778-778: Good improvement to thread safety for whitespace skipping.

Moving the whitespace-skipping guard from a per-instance field to per-parse context methods (isSkippingWhitespace(), enterWhitespaceSkip(), exitWhitespaceSkip()) eliminates potential race conditions when parser instances are reused across threads. The try-finally block ensures proper cleanup even if parsing fails.

Also applies to: 782-803


293-293: Excellent consolidation of duplicate expression parsing logic.

The unified parseExpressionWithMode() dispatcher with ParseMode (standard, withActions, noWhitespace) eliminates significant code duplication. All call sites are consistently updated to use the mode-aware dispatcher, making the code more maintainable and easier to extend.

Also applies to: 326-326, 386-386, 406-406, 422-422, 662-662, 673-673, 691-691, 710-710, 721-721, 736-736, 1159-1193

CLAUDE.md (1)

21-21: Documentation accurately reflects API and dependency changes.

The updates correctly document:

  • Dependency upgrade to pragmatica-lite:core 0.9.0
  • Builder API method renames (.packrat(), .trivia(), .recovery())
  • Test count increase to 271

All documentation changes are consistent with the code modifications.

Also applies to: 133-133, 176-178, 252-252

CHANGELOG.md (1)

8-58: Excellent release documentation with comprehensive technical details.

The 0.1.6 changelog entry is well-structured and thorough:

  • Added section documents new features (AST support, packrat toggle, unlimited $N variables)
  • Fixed section highlights important bug fixes (grammar validation, thread safety, cache key collisions)
  • Changed section covers API improvements and code simplifications (~120 lines eliminated)

The specific technical details (e.g., "cache key from hashCode() to unique sequential IDs") make it easy to understand the impact of each change. The format follows Keep a Changelog conventions.

src/main/java/org/pragmatica/peg/parser/PegEngine.java (4)

77-77: LGTM: Centralized error building improves consistency.

The refactoring to use buildParseError consolidates error construction logic, making it easier to maintain consistent error messages across different parsing paths.

Also applies to: 134-134


775-806: LGTM: Whitespace lifecycle management prevents recursion and ensures cleanup.

The addition of isSkippingWhitespace() check at line 778 prevents infinite recursion when the whitespace grammar itself needs whitespace parsing. The try-finally block (lines 782-803) ensures exitWhitespaceSkip() is always called, even if parsing throws an exception.

According to the PR objectives, moving whitespace state into ParsingContext also addresses thread safety concerns since each parse creates its own context.


293-293: LGTM: Mode-aware parsing consolidates duplicate code effectively.

The refactoring replaces three separate methods (parseExpression, parseExpressionWithActions, parseExpressionNoWs) with a unified parseExpressionWithMode dispatcher. Mode selection is appropriate across all call sites:

  • standard() for normal CST parsing (lines 293, 662, 673, 691, 710, 721, 736)
  • withActions() when collecting semantic values and executing actions (lines 326, 386, 406, 422)
  • noWhitespace() when parsing whitespace itself (line 791) — critical for preventing infinite recursion

This consolidation reduces code duplication and improves maintainability.

Also applies to: 326-326, 386-386, 406-406, 422-422, 662-662, 673-673, 691-691, 710-710, 721-721, 736-736, 791-791


1158-1162: LGTM: Clear documentation of the unified parsing method.

The comment accurately describes the three parsing modes (standard, withActions, noWhitespace) supported by the consolidated method.

@siy siy merged commit f88404f into main Dec 27, 2025
2 checks passed
@siy siy deleted the release-0.1.6 branch December 27, 2025 13:57
@coderabbitai coderabbitai bot mentioned this pull request Dec 31, 2025
3 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant